package app.autolist;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class Test extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        final TextView back = findViewById(R.id.back);
        final EditText text1 = (EditText) findViewById(R.id.text1);
        text1.setText(getIntent().getStringExtra("content"));
        text1.setFocusable(true);
        text1.setFocusableInTouchMode(true);
        text1.requestFocus();
        text1.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                Intent intent = new Intent();
                intent.putExtra("content",text1.getText().toString().trim());
                setResult(Activity.RESULT_OK,intent);
                finish();
                return true;
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @SuppressLint("ShowToast")
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                getDate gs = new getDate();
                gs.input(text1.getText().toString());
                intent.putExtra("content",gs.output());
                /*Intent intent = new Intent();
                intent.putExtra("content",text1.getText().toString().trim());*/
                setResult(Activity.RESULT_OK,intent);
                finish();
            }
        });
    }
}